/* Pardus Sector Tool
 * (C) Yassen 2010
 *
 * constants.js
 * Defines constants used throughout the tool.
 *
 * Constants:
 * 
 * eNull
 * eBuilding
 * ePlanet
 * eStarbase
 * eBackground
 * NPC
 *
 * TileType
 *   Null
 *   Space
 *   Energy
 *   Nebula
 *   Asteroids
 *   Exotic_Matter
 *   Viral_Cloud
 *
 * PacketType
 *
 * 
 * Functions:
 * String    TileTypeToAbbr(TileType tile)
 * TileType  AbbrToTileType(String abbr)
 *
 */

var eNull = "null";
var eBuilding = "Building";
var ePlanet = "Planet";
var eStarbase = "Starbase";
var eBackground = "Background";

var TileType = {Null: 0,
                Space: 1,
                Energy: 2,
                Nebula: 4,
                Asteroids: 8,
                Exotic_Matter: 16,
                Viral_Cloud: 32,
                Solid_Energy: 64};

var NPC = 0xFF;

var PacketType = {
  eNullType: -1,

  eAddSectorType: 0,
  eRemoveSectorType: 1,
  eLoadSectorType: 2,
  eGetSectorsType: 3,
  eAddPricelistType: 4,
  eRemovePricelistType: 5,
  eLoadPricelistType: 6,
  eGetPricelistsType: 7,

  eRegisterType: 8,
  eLoginType: 9,
  eDeleteUserType: 10,

  eHeartbeatType: 11
};

function TileTypeToAbbr(tile)
{
  // <summary>Converts a TileType to Abbreviation (for use in displaying maps)</summary>
  // <param name="tile" type="TileType">TileType to Convert</param>
  // <returns type="String">Returns the abbreviation</returns>
  
  switch(tile)
  {
    case TileType.Space: return "f"; break;
    case TileType.Energy: return "e"; break;
    case TileType.Nebula: return "g"; break;
    case TileType.Asteroids: return "o"; break;
    case TileType.Exotic_Matter: return "m"; break;
    case TileType.Viral_Cloud: return "v"; break;
    case TileType.Solid_Energy: return "b"; break;
    default: return ""; break;
  }
}

function AbbrToTileType(abbr)
{
  // <summary>Converts an Abbreviation to TileType.</summary>
  // <param name="abbr" type="String">Abbreviation to Convert</param>
  // <returns type="TileType">Returns the TileType</returns>

  switch (abbr.toLowerCase())
  {
    case "f": return TileType.Space; break;
    case "e": return TileType.Energy; break;
    case "g": return TileType.Nebula; break;
    case "o": return TileType.Asteroids; break;
    case "m": return TileType.Exotic_Matter; break;
    case "v": return TileType.Viral_Cloud; break;
    case "b": return TileType.Solid_Energy; break;
    default: return TileType.Null; break;
  }
}